import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

/**
 * @ClassName Demo01_ObjectOuputStream
 * @Description 将指定的对象写出
 * @Author Li
 * @Date 2022/8/12 21:05
 * @ModifyDate 2022/8/12 21:05
 * @Version 1.0
 */
public class Demo01_ObjectOutputStream {
    public static void main(String[] args) {
        Student student = new Student("张三", 18, 101);
        try {
            // 创建序列化对象
            ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("src/part10/ch03_Serializable/student.txt"));
            // 写对象
            oos.writeObject(student);
            // 释放资源
            oos.close();
            System.out.println("Serialized data over"); // 姓名，年龄被序列化，编号没有被序列化

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
